<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\AuthenticationController;
use App\Http\Controllers\UserController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

// Public routes
Route::group(
  [
    'middleware' => ['language'],
  ],
  function () {
    Route::get('/', [HomeController::class, 'home']);
    // Auth routes
    Route::get('/login', [AuthenticationController::class, 'showLoginForm']);
    Route::post('/login', [AuthenticationController::class, 'login']);
  }
);

// Protected routes
Route::group(
  [
    'middleware' => ['language', 'auth'],
  ],
  function () {
    // Auth routes
    Route::get('/logout', [AuthenticationController::class, 'logout']);
    // User routes
    Route::get('/users', [UserController::class, 'index']);
    Route::get('/users', [UserController::class, 'index']);
    Route::post('/users/create', [UserController::class, 'create']);
    Route::get('/users/{id}', [UserController::class, 'show']);
    Route::get('/users/edit/{id}', [UserController::class, 'edit']);
    Route::put('/users/{id}', [UserController::class, 'update']);
    Route::delete('/users/{id}', [UserController::class, 'destroy']);
    Route::post('/users/search', [UserController::class, 'search']);
  }
);